User Input Value || Taking value from user || C++

In this, we are going to see how to take user-input or values for user in our C++ program.

The Code given below can be used in Turbo C++ Compiler.

#include<iostream.h>
#include<conio.h>

void main()
{
    clrscr();
    
    // variable declaration
    int a;
    cout<<"Enter value for a ";

    // taking input from user
    cin>>a ;
    cout<<"value of a is :"<<a;
    getch();
}
    
    

The Code given below can be used in g++/gcc Compiler.

#include<iostream>
using namespace std;
int main()
{

    // variable declaration
    int a;
    cout<<"Enter value for a ";

    // taking input from user
    cin>>a ;
    cout<<"value of a is :"<<a;
    return 0;
}
    
    

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post